#include<stdio.h>
#include "stack.h"
#include<stdlib.h>
#include <assert.h>
#include <crtdbg.h>
int proverka(char ch[256]) 
{
	// ( - 1 ; { - 2; [ - 3; < -4;

	int i,t;
	Stack s;
	stack_create(&s);
	 
	for(i=0;i<256;i++)
	{
		t=10;
		switch (ch[i]) 
		{ 
			case '(': t=1; break; 
			case '{': t=2; break; 
			case '[': t=3; break; 
			case '<': t=4; break; 

			case ')': t=-1; break; 
			case '}': t=-2; break; 
			case ']': t=-3; break; 
			case '>': t=-4; break; 
			default : ; 
		} 



		if( (int)stack_peek(&s) == -t )
			stack_pop(&s);
		else 
			if(t !=10)
			stack_push(&s, (Pointer)t);


	}

	if ((int)stack_size(&s) == 0)
	{
		stack_destroy(&s);
		return (1);
	}
	
	stack_destroy(&s);
	return (0);
}


void main()
{
	
	assert(proverka("{()[()]}<<<>>>")  == 1);
	assert(proverka("{}()<({}<>)>")  == 1);
	
	assert(proverka("[(])")  == 0);
	assert(proverka("{{[]]}}")  == 0);

	_CrtDumpMemoryLeaks();
	
	system("PAUSE");
}